<template>
	<view class="">
		<view class="background"></view>
		<navView navTitle="付款列表" backgroundColor="#008efe" titleColor="#fff" :isBack="true">
		</navView>
		<view class="topBox" :style="{ top: 43 + statusBarHeight + 'px' }">
			<view class="stateList">
				<view :class="state_index == index?'items':'item'" v-for="(item,index) in stateList" :key="index"
					@tap="tapState(index)">
					{{item.name}}
					<view class="tiao" v-if="state_index == index"></view>
				</view>
			</view>
		</view>
		<view style="height: 70rpx;">
		</view>
		<view class="project-box" v-if="user_status == 2">
			<view class="project-list2" v-if="state_index != 2">
				<view class="project-card" v-for="(project, index) in projects" :key="index" @tap="showModal = true">
					<!-- 项目名称和状态 -->
					<view class="project-header">
						<text>此时为项目名称</text>
						<text
							:class="['status-tag', project.status == 1 ? 'completed' :project.status == 2 ? 'ongoing' :project.status == 3 ? 'not-started' : '']">
							{{ project.status == 1?'已完成':project.status == 2?'进行中':project.status == 3?'未开始':'' }}
						</text>
					</view>
					<!-- 负责人信息 -->
					<view class="project-detail">
						<view class="userbox">
							销售：{{ project.sales }}
							<!-- 电话号码 -->
							<view class="phone-wrapper">
								<image class="image" src="https://hfd.bjlzkj.com/static/list/phone-icon.png" mode=""></image>
								<text>{{ project.phone }}</text>
							</view>
						</view>

					</view>
					<view class="project-price">
						待付款金额：<text>500000元</text>
					</view>
					<!-- 功能标签栏 -->
					<view class="tab-bar">
						<text class="tab-item"
							@tap="$navTo('/subpkg/contract/contractDetail/contractDetail')">合同详情</text>
						<text class="tab-item"
							@tap="$navTo('/subpkg/contract/contractState/contractState')">项目成果</text>
						<text class="tab-item" @tap="$navTo('/subpkg/contract/pay/pay')">合同付款</text>
						<text class="tab-item"
							@tap="$navTo('/subpkg/contract/contractForm/contractForm')">开票情况</text>
					</view>
				</view>
			</view>
		</view>
		<view v-if="showModal" class="popup-box">
			<!-- 弹出层内容 -->
			<view class="popup-content">
				<text class="popup-title">发送付款提醒</text>
				<text class="popup-item">客户姓名：张三</text>
				<text class="popup-item">合同链接：{{ contractLink }}</text>
				<button class="popup-button" @click="handleSend">点击发送</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				projects: [{
						name: '项目一',
						status: 1,
						sales: '张静',
						technical: '王子初',
						finance: '罗婷',
						admin: '徐昊',
						phone: '13025689523',
					},
					{
						name: '项目二',
						status: 2,
						sales: '张静',
						technical: '王子初',
						finance: '罗婷',
						admin: '徐昊',
						phone: '15862140021',
					},
					{
						name: '项目三',
						status: 3,
						sales: '张静',
						technical: '王子初',
						finance: '罗婷',
						admin: '徐昊',
					},
				],
				user_status: 2,
				statusBarHeight: '',
				stateList: [{
						name: '待付款',
						value: 1
					},
					{
						name: '已付款',
						value: 2
					},
					{
						name: '已完成',
						value: 3
					},
				],
				state_index: 0,
				showModal: false, // 控制弹出层的显示状态
				contractLink: 'https://www.com/pins/3510938564' // 合同链接示例
			}
		},
		onLoad() {
			const app = getApp();
			// 获取机型状态栏信息
			const {
				statusBarHeight,
			} = app.globalData;
			this.statusBarHeight = statusBarHeight;
		},
		methods: {
			handleEvaluation(project) {
				uni.navigateTo({
					url: `/pages/evaluation/evaluation?projectId=${project.name}`,
				});
			},
			tapState(ind) {
				this.state_index = ind
			},
			handleSend() {
				// 点击发送按钮的逻辑
				console.log('发送付款提醒');
				this.showModal = false; // 关闭弹出层
			}
		}
	}
</script>

<style lang="scss">
	.background {
		background: #f5f6f9;
		width: 100%;
		height: 100vh;
		position: fixed;
		top: 0;
		left: 0;
		z-index: -1;
	}

	.topBox {
		width: 100%;
		position: fixed;
		left: 0;

		.stateList {
			width: 100%;
			background: #fff;
			display: flex;
			align-items: center;
			justify-content: space-around;

			.items {
				font-weight: bold;
				font-size: 30rpx;
				color: #008EFE;
				position: relative;
				padding: 20rpx 0;

				.tiao {
					width: 38rpx;
					height: 4rpx;
					background: #64AFFF;
					border-radius: 2rpx 2rpx 2rpx 2rpx;
					position: absolute;
					bottom: 0rpx;
					left: 50%;
					transform: translate(-50%);
				}
			}

			.item {
				font-size: 30rpx;
				color: #AFAFB2;
				padding: 20rpx 0;
			}
		}
	}


	.project-box {
		padding: 20rpx;
		box-sizing: border-box;

		.project-list2 {

			.project-title {
				display: flex;
				align-items: center;
				justify-content: space-between;
				background: #e5f3ff;
				padding: 26rpx 20rpx;
				box-sizing: border-box;
				border-top-left-radius: 16rpx;
				border-top-right-radius: 16rpx;
				font-weight: 400;
				font-size: 24rpx;
				color: #B0B0B0;

				.tite {
					font-weight: bold;
					font-size: 30rpx;
					color: #333333;
				}
			}

			.project-card {
				overflow: hidden;
				margin-bottom: 20rpx;
				padding: 20rpx;
				margin: 20rpx 0;
				border-radius: 16rpx;
				background-color: #fff;

				.project-header {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-bottom: 10rpx;

					text {
						font-size: 32rpx;
						font-weight: bold;
					}

					.status-tag {
						border-radius: 10rpx;
						padding: 6rpx 12rpx;
						font-size: 24rpx;
						font-weight: bold;
						color: #fff;

						&.completed {
							background-color: #FFAA00;
						}

						&.ongoing {
							background-color: #007aff;
						}

						&.not-started {
							background-color: #ff3a3a;
						}
					}
				}

				.project-price {
					font-weight: 400;
					font-size: 24rpx;
					color: #7D7D7D;

					text {
						color: #000000;
					}
				}

				.project-detail {
					font-size: 28rpx;
					color: #333;
					margin-bottom: 20rpx;
					display: flex;
					align-items: center;

					.userbox {
						position: relative;
					}

					.phone-wrapper {
						position: absolute;
						bottom: -50rpx;
						left: 0;
						z-index: 10;
						display: flex;
						align-items: center;
						margin-top: 10rpx;
						background: #fff;
						box-shadow: 0 2rpx 6rpx 2rpx #c1c1c1;
						padding: 3rpx 5rpx;
						box-sizing: 10rpx;

						.image {
							width: 32rpx;
							height: 32rpx;
							margin-right: 10rpx;
						}
					}
				}

				.tab-bar {
					display: flex;
					justify-content: space-between;
					margin-bottom: 20rpx;

					.tab-item {
						width: 20%;
						text-align: center;
						padding: 8rpx 0;
						background-color: #e0f1ff;
						border-radius: 10rpx;
						color: #007aff;
						font-size: 24rpx;
					}
				}

				.service-evaluation {
					display: flex;
					justify-content: space-between;
					align-items: center;
					font-size: 24rpx;
					color: #E56C2B;
					background-color: #F5F5F5;
					padding: 10rpx 10rpx;
					box-sizing: border-box;
					border-radius: 10rpx;

					.right {
						width: 8rpx;
						height: 16rpx;
						margin-left: 20rpx;
					}
				}
			}
		}
	}

	/* 弹出层的整体样式 */
	.popup-box {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		/* 半透明背景 */
		transition: all 0.3s ease;
		/* 添加动画 */
	}

	.popup-box.hidden {
		transform: translateY(100%);
	}

	.popup-content {
		background-color: #fff;
		border-radius: 16px 16px 0 0;
		padding: 20px;
		width: 80%;
		max-width: 400px;
		box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
	}

	.popup-title {
		font-size: 18px;
		font-weight: bold;
		margin-bottom: 10px;
	}

	.popup-item {
		font-size: 14px;
		margin-bottom: 10px;
	}

	.popup-button {
		width: 100%;
		height: 40px;
		border-radius: 20px;
		background-color: #1890ff;
		color: #fff;
		font-size: 16px;
		margin-top: 20px;
	}
</style>